<?php

	/**
	 * This is the page header.
	 */ 
	function displayHeader() {
		
		global $config;
		
		
		echo "<html lang=\"en\" xml:lang=\"en\">";
		echo "	<head>";
		echo 		'<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />';
		echo 		'<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>';
		echo "		<title>".$config['pagetitle']."</title>";	
		
		echo 		'<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>';
		
		echo "		<link type=\"text/css\" rel=\"stylesheet\" href=\"css/style.css\">";
		echo "	</head>";
		echo "	<body>";
		echo "		<div id=\"wrapper\">";
	}
	
	
	/**
	 * This is the page footer
	 */
	function displayFooter() {
		
		global $config;
		
		
		echo "		</div>";
		echo "<br /><br /><br /><br />";
		echo"			<p align=\"center\">&copy; Powered by DataWave, 2012</p>";
		echo "	</body>";
		echo "</html>";
		
	}
	
	/**
	 * This is the navigation.
	 */
	function displayNavigation() {
		echo "<div id=\"navigation\">";
		
		if($_SESSION['level'] > 0) {
			echo "	<div class=\"button\"><a href=\"index.php?action=home\">Home</a></div>";
		
			echo ' <form id="queryselect" name="queryselect" method="post" action="index.php?action=selectquery">
					<select name="querydropdown">
				<option value="stationsQuery1">Daily: Summary of stations with 20-30 Peak Temperature AND 5-10 Avg. Rainfall</option>
				<option value="stationsQuery2">Weekly: Summary of stations on latitude 15 and Avg. Temperature > 20</option>
				<option value="map">Real-time: Graph with cloud coverage</option>
				</select>
					<input type="submit" value = "Go" name="submitquery" />';
				
			echo "	<div class=\"button\"><a href=\"index.php?action=displayChangePassword\">Change password</a></div>";
		}
		if($_SESSION['level'] > 1) {
			echo "	<div class=\"button\"><a href=\"index.php?action=admin\">Admin</a></div>";
		}
		if($_SESSION['level'] > 0) {
			echo "	<div class=\"button\"><a href=\"index.php?action=logout\">Log out</a></div>";
		}
		echo '</form>';
		echo "</div>";
	}
	
	function selectquery() {
		header('Location: index.php?action='.$_POST['querydropdown']);
	}

	
	/**
	 * This function gets the current action from the URL. 
	 * If no action is selected, the default action will be returned.
	 *
	 */
	function getCurrentAction() {
		global $config;
		
		if(isset($_GET['action']) == true) {
			return $_GET['action'];
		}
		else {
			return $config['defaultaction'];
		}
	}


?>